package com.atguigu.product.entity;

import com.atguigu.common.valid.AddValid;
import com.atguigu.common.valid.ListValid;
import com.atguigu.common.valid.updateStatus;
import com.atguigu.common.valid.updateValid;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import javax.validation.constraints.*;

import lombok.Data;
import org.hibernate.validator.constraints.URL;

/**
 * 品牌
 * 
 * @author litong
 * @email 2943284183@qq.com
 * @date 2024-08-07 18:11:07
 */
@Data
@TableName("pms_brand")
public class BrandEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * 品牌id
	 */
	@TableId
	@NotNull(message = "修改时品牌id不能为空",groups = {updateValid.class})
	@Null(message = "新增时品牌id必须为空",groups = {AddValid.class})
	private Long brandId;
	/**
	 * 品牌名
	 */
//	检索，非空且不能是空格
	@NotBlank(message = "品牌名不能为空",groups = {AddValid.class})
	private String name;
	/**
	 * 品牌logo地址
	 */

//	检索，必须是url且非空
	@NotEmpty(message = "logo不能为空",groups = {AddValid.class})
	@URL(message = "logo必须是一个合法的URL信息",groups = {AddValid.class, updateValid.class})
	private String logo;
	/**
	 * 介绍
	 */
	@NotNull(message = "介绍不能为空",groups = {AddValid.class})
	private String descript;
	/**
	 * 显示状态[0-不显示；1-显示]
	 */
	@NotNull(message = "状态不能为空",groups = {AddValid.class, updateStatus.class})
	@ListValid(vals={0,1},groups = {AddValid.class, updateStatus.class})
	private Integer showStatus;
	/**
	 * 检索首字母
	 */
//	自定义检索规则
//			groups是指定分组，即在什么时候进行校验，在controller里面指定某一个分组
	@Pattern(regexp = "^[a-zA-Z]$",message = "检索首字母必须是a-z或-Z的字母",groups = {AddValid.class})
	private String firstLetter;
	/**
	 * 排序
	 */
	@NotNull(groups = {AddValid.class})
	@Min(value = 0,message = "排序必须大于等于0",groups = {AddValid.class, updateValid.class})
	private Integer sort;

}
